home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / TCL1 / DYNAMICA / CBIG2D.H < prev    next >
Text File  |  1990-07-01  |  4KB  |  103 lines

  1. /******************************************************************************
  2.  
  3.  
  4.     Class: Big2D
  5.     
  6.     This class implements two dimensional arrays that can be larger than
  7.     32K and store any kind of elements.
  8.     
  9.     By: Eric Yiskis
  10.     November 19, 1989
  11.     
  12.  ******************************************************************************/
  13.  
  14. #define _H_CBig2D
  15.  
  16. #include <Global.h>                    /*  handy declarations                 */
  17. #include <CObject.h>                /* Interface for its superclass        */
  18. #include <CDataFile.h>
  19. #include <CApplication.h>
  20.  
  21. extern CApplication        *gApplication;
  22.  
  23. /*-------------------------------------------------------------------------------*/                        
  24.  
  25. typedef struct {
  26.     int        nXLimit,nYLimit;    /* X and Y dimensions of array         */
  27.     int        nElementSize;        /* length in bytes of each element     */
  28. } AMFData2D;                      /* Array Mapping Function data */
  29.  
  30. /*-------------------------------------------------------------------------------*/                        
  31.  
  32. struct CBig2D : CObject {    
  33.  
  34.     /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/                        
  35.     /* Instance Variables */
  36.     
  37.     Handle        hData;
  38.     AMFData2D    amf;
  39.  
  40.     /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/                        
  41.     /* Instance Methods */
  42.     
  43.     /*-- Creation/Termination --*/
  44.     void    IBig2D(void);
  45.     /* pre - Object has been allocated but not initialized                    */
  46.     /* post- Object has been initialized                                    */
  47.     
  48.     Boolean    CreateData(int nXMax,int nYMax,int nElementSizeIn,Handle hDataIn);
  49.     /* pre - Object has been initialized but not created by CreateData or    */
  50.     /*         LoadData.                                                        */
  51.     /*         hDataIn contains NULL or contains data that matches nXMax        */
  52.     /*         nYMax, and nElementSizeIn dimension parameters.                */
  53.     /* post- if hDataIn == NULL, returns TRUE if array matching the         */
  54.     /*         dimensions could be allocated, otherwise returns FALSE.         */
  55.     /*         if hDataIn != NULL, hDataIn is assumed to be an array that     */
  56.     /*         matches the dimension parameters.                                */
  57.     /* note- If loading an object from a file, use the LoadData method to    */
  58.     /*         instead.                                                        */ 
  59.     
  60.     void    Dispose(void);            /* OVERRIDE */
  61.     
  62.     
  63.     /*-- Element Manipulation --*/
  64.     void    SetValue(int nX,int nY,char *pSource);    
  65.     /* pre - Object has been created by CreateData or LoadData methods        */
  66.     /* post- data at pSource is copied into location nX,nY                    */
  67.     
  68.     void    GetValue(int nX,int nY,char *pDestination);
  69.     /* pre - Object has been created by CreateData or LoadData methods        */
  70.     /* post- data at pSource is copied into location nX,nY                    */
  71.     
  72.     /*-- I/O --*/
  73.     OSErr     LoadData(CDataFile *datafile);
  74.     /* pre - Object has been initialized but not created by CreateData or    */
  75.     /*         LoadData.                                                        */
  76.     /*         datafile is open.                                                */
  77.     /* post- returns the error condition of the attempt to read.            */
  78.     /*       if the error condition == NoErr then the object is                */
  79.     /*          initialized with the data from datafile.                         */
  80.     
  81.     OSErr    SaveData(CDataFile *datafile);
  82.     /* pre - Object has been created by CreateData or LoadData methods        */
  83.     /*         datafile is open.                                                */
  84.     /* post- returns the error condition of the attempt to write.            */
  85.     /*          if the error condition == NoErr then the data has been written */
  86.  
  87.     
  88.     /*-- Misc --*/
  89.     void    GetDimensions(int *nX, int *nY, int *nElementSizeOut);
  90.     /* pre - Object has been created by CreateData or LoadData methods        */
  91.     /* post- parameters contain dimensions of the array.                    */
  92.     
  93.     Handle    GetData(void);
  94.     /* pre - Object has been created by CreateData or LoadData methods        */
  95.     /* post- Returns a handle to the data.                                    */
  96.     
  97.     /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/    
  98.     /* private */
  99.     
  100.     long    Offset(int nX,int nY);     
  101.     /* returns offset (bytes) of element from the beginning of the data handle */
  102. };
  103.